﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;

using Tradex;
using Tradex.Messages;

namespace Tradex.Connectivity {

    /// <summary>
    /// This interface is used by the ConnectivityServer to control a connector. This interface defines
    /// the complete control interface for operational life cycle controls.
    /// A message bus wrapper in two methods (SubmitMessages and RetrieveMessages) is used to control
    /// the functional aspects via standard messages.
    /// </summary>
    [ServiceContract (SessionMode=SessionMode.Allowed)]
    public interface IConnectorApi {

        /// <summary>
        /// Calls the pint method.
        /// </summary>
        /// <returns></returns>
        [OperationContract ()]
        Guid Ping();

        /// <summary>
        /// Connect given specific configuration information. If currently connected to
        /// a different configuration, throw an exception. If already connected to the same
        /// configuration, ignore.
        /// </summary>
        /// <param name="info"></param>
        [OperationContract()]
        void Connect(ConnectionInfo info);

        /// <summary>
        /// Disconnect.
        /// </summary>
        [OperationContract()]
        void Disconnect();

        /// <summary>
        /// Shutdown the wrapper. Disconnect if necessary. This is mostly used to regularly
        /// (sundays) cycle wrappers. This method should block as long as possible an return
        /// basically when the connector has been disconnected. The communication infrastructure
        /// should shut down immediately after.
        /// </summary>
        [OperationContract()]
        void Shutdown();

        /// <summary>
        /// Submits the array of messages into the ingoing queue of the wrapper for processing.
        /// </summary>
        /// <param name="messages"></param>
        [OperationContract()]
        void SubmitMessages(Message[] messages);

    }

}
